import { AppRouteRecordRaw } from '@/types/router'
import Layout from '@/layout/index.vue'
import { defineAsyncComponent } from 'vue'

export const asyncRoutes: AppRouteRecordRaw[] = [
  {
    path: '/permission',
    component: Layout,
    redirect: '/permission/page',
    name: 'Permission',
    meta: {
      title: '权限管理',
      icon: 'lock',
      roles: ['admin', 'editor'],
      alwaysShow: true
    },
    children: [
      {
        path: 'page',
        component: defineAsyncComponent(() => import('@/views/permission/page.vue')),
        name: 'PagePermission',
        meta: {
          title: '页面权限',
          roles: ['admin']
        }
      },
      {
        path: 'directive',
        component: defineAsyncComponent(() => import('@/views/permission/directive.vue')),
        name: 'DirectivePermission',
        meta: {
          title: '指令权限'
        }
      },
      {
        path: 'role',
        component: defineAsyncComponent(() => import('@/views/permission/role.vue')),
        name: 'RolePermission',
        meta: {
          title: '角色权限',
          roles: ['admin']
        }
      }
    ]
  },
  {
    path: '/system',
    component: Layout,
    redirect: '/system/user',
    name: 'System',
    meta: {
      title: '系统管理',
      icon: 'component',
      roles: ['admin'],
      alwaysShow: true
    },
    children: [
      {
        path: 'user',
        component: defineAsyncComponent(() => import('@/views/system/user/index.vue')),
        name: 'User',
        meta: {
          title: '用户管理',
          roles: ['admin']
        }
      },
      {
        path: 'role',
        component: defineAsyncComponent(() => import('@/views/system/role/index.vue')),
        name: 'Role',
        meta: {
          title: '角色管理',
          roles: ['admin']
        }
      },
      {
        path: 'menu',
        component: defineAsyncComponent(() => import('@/views/system/menu/index.vue')),
        name: 'Menu',
        meta: {
          title: '菜单管理',
          roles: ['admin']
        }
      }
    ]
  }
] 